package com.wgh.pay.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 支付配置管理器
 */
@Component
@ConfigurationProperties(prefix = "pay")
public class PayConfigManager {
    
    // 微信支付配置
    private Map<String, String> wechat = new HashMap<>();
    
    // 支付宝配置
    private Map<String, String> alipay = new HashMap<>();
    
    // 银联支付配置
    private Map<String, String> unionpay = new HashMap<>();
    
    // 支付超时时间配置（分钟）
    private Integer timeout = 30;
    
    // 退款申请有效期（天）
    private Integer refundExpireDays = 90;
    
    // 通知最大重试次数
    private Integer notifyMaxRetries = 5;
    
    // 通知重试间隔（秒）
    private Integer notifyRetryInterval = 60;
    
    /**
     * 根据支付类型获取支付配置
     * @param payType 支付类型
     * @return 支付配置
     */
    public Map<String, String> getPayConfigByType(Integer payType) {
        switch (payType) {
            case 1: // 微信支付
                return wechat;
            case 2: // 支付宝
                return alipay;
            case 3: // 银联支付
                return unionpay;
            default:
                return new HashMap<>();
        }
    }
    
    /**
     * 获取微信支付配置
     */
    public Map<String, String> getWechat() {
        return wechat;
    }
    
    /**
     * 设置微信支付配置
     */
    public void setWechat(Map<String, String> wechat) {
        this.wechat = wechat;
    }
    
    /**
     * 获取支付宝配置
     */
    public Map<String, String> getAlipay() {
        return alipay;
    }
    
    /**
     * 设置支付宝配置
     */
    public void setAlipay(Map<String, String> alipay) {
        this.alipay = alipay;
    }
    
    /**
     * 获取银联支付配置
     */
    public Map<String, String> getUnionpay() {
        return unionpay;
    }
    
    /**
     * 设置银联支付配置
     */
    public void setUnionpay(Map<String, String> unionpay) {
        this.unionpay = unionpay;
    }
    
    /**
     * 获取支付超时时间
     */
    public Integer getTimeout() {
        return timeout;
    }
    
    /**
     * 设置支付超时时间
     */
    public void setTimeout(Integer timeout) {
        this.timeout = timeout;
    }
    
    /**
     * 获取退款申请有效期
     */
    public Integer getRefundExpireDays() {
        return refundExpireDays;
    }
    
    /**
     * 设置退款申请有效期
     */
    public void setRefundExpireDays(Integer refundExpireDays) {
        this.refundExpireDays = refundExpireDays;
    }
    
    /**
     * 获取通知最大重试次数
     */
    public Integer getNotifyMaxRetries() {
        return notifyMaxRetries;
    }
    
    /**
     * 设置通知最大重试次数
     */
    public void setNotifyMaxRetries(Integer notifyMaxRetries) {
        this.notifyMaxRetries = notifyMaxRetries;
    }
    
    /**
     * 获取通知重试间隔
     */
    public Integer getNotifyRetryInterval() {
        return notifyRetryInterval;
    }
    
    /**
     * 设置通知重试间隔
     */
    public void setNotifyRetryInterval(Integer notifyRetryInterval) {
        this.notifyRetryInterval = notifyRetryInterval;
    }
}